<template>
  <div>
    <el-table :data="goods.tableData" border style="width: 100%" current-row-key="index">
      <el-table-column prop="id" label="ID" min-width="80"></el-table-column>
      <el-table-column prop="name" label="商品名称" width="250" min-width="80"></el-table-column>
      <el-table-column prop="retail_price" label="售价" min-width="80"></el-table-column>
      <el-table-column prop="goods_number" label="库存" min-width="80"></el-table-column>
      <el-table-column label="新品" min-width="80">
        <template slot-scope="scope">{{goods.tableData[scope.$index].is_new?'是':'否'}}</template>
      </el-table-column>
      <el-table-column label="人气" min-width="80">
        <template slot-scope="scope">{{goods.tableData[scope.$index].is_hot?'是':'否'}}</template>
      </el-table-column>
      <el-table-column label="上架" min-width="80">
        <template slot-scope="scope">{{goods.tableData[scope.$index].is_delete?'否':'是'}}</template>
      </el-table-column>
      <el-table-column prop="sort_order" label="排序" min-width="80"></el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
            @click="deletelist(scope.$index,goods.tableData[scope.$index].id)"
            type="primary"
            size="small"
          >编辑</el-button>
        </template>
      </el-table-column>
    </el-table>



  </div>
</template>

<script>
//引入API
import { getAdminGoods } from "@/request/api.js";
//引入vuex
import { mapState } from "vuex";

export default {
  created() {
    this.$store.dispatch("changetableDatas");
  },
  computed: {
    ...mapState(["goods"])
  },
  data() {
    return {
      tableData: [
        {
          date: "54656",
          name: "牛叔",
          address: "北京"
        }
      ],
      index: 1
    };
  },
  //   方法
  methods: {
    deletelist(e, id) {
      console.log(e, id);
      this.$router.push({
        path:`/editgood/${id}`,
        params:{
          id
        }
      })
    }
  }
};
</script>

<style lang='less' scoped>

</style>